package com.zbkj.service.model.front.req.recycle;

import com.zbkj.dal.annotation.EnumValue;
import com.zbkj.dal.base.enums.BizTypeEnum;
import com.zbkj.dal.base.enums.ProductParts;
import com.zbkj.dal.base.enums.QualityEnum;
import com.zbkj.dal.base.enums.BizShareModeEnum;
import com.zbkj.dal.entity.ba.BizImg;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import java.time.LocalDateTime;
import java.util.List;

@Data
@ApiModel
public class SupplyApplyReq {

    /**
     * @see BizShareModeEnum
     */
    @ApiModelProperty(value = "回收类型", required = true, example = "SUPPORT_VALUE")
    @NotBlank(message = "回收类型 不能为空")
    @EnumValue(value = BizShareModeEnum.class, message = "回收类型不正确")
    private String supplyType;

    @ApiModelProperty(value = "商品类型", required = true, example = "")
    @NotBlank(message = "商品类型 不能为空")
    private String productType;

    @ApiModelProperty(value = "品牌", required = true, example = "LV")
    @NotBlank(message = "品牌 不能为空")
    private String brand;

    @ApiModelProperty(value = "型号", required = false, example = "LV 0001")
    private String model;

    /**
     * @see QualityEnum
     */
    @ApiModelProperty(value = "成色", required = true, example = "ENTIRELY_NEW")
    @NotBlank(message = "成色 不能为空")
    private String quality;

    /**
     * @see ProductParts
     */
    @ApiModelProperty(value = "配件", required = true, example = "[]")
    @NotEmpty(message = "配件 不能为空")
    private List<String> parts;

    @ApiModelProperty(value = "图片信息", required = true)
    @NotEmpty(message = "图片信息 不能为空")
    private List<ProductUrl> productUrls;

    @ApiModelProperty(value = "描述", required = false, example = "描述")
    private String description;

    @Data
    public static class ProductUrl {
        /**
         * @see com.zbkj.dal.base.enums.RecyclePositionEnums
         */
        @ApiModelProperty(value = "图片类型", required = true, example = "POSITIVE")
        private String type;

        @ApiModelProperty(value = "图片地址", example = "*****")
        private String url;
    }

    public static BizImg generateBizImg(Integer bizId, String url, String position) {
        BizImg bizImg = new BizImg();
        bizImg.setBizId(bizId);
        bizImg.setPath(url);
        bizImg.setType(BizTypeEnum.SHARE.getType());
        bizImg.setPosition(position);
        bizImg.setCreateTime(LocalDateTime.now());
        bizImg.setUpdateTime(LocalDateTime.now());
        return bizImg;
    }
}
